home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Information / WebSites / Wirenet / files / 0800timer.lha / 0800Timer next >
Text File  |  2000-03-20  |  2KB  |  88 lines

  1. /*
  2.     0800timer - keeps track of 0800 usage at weekends
  3. */
  4.  
  5. /* ;;; Exit and clear environment variable if a weekday */
  6. if left(date('W'),1) ~= 'S' then do
  7.     call addlib('rexxsupport.library',0,-30,0)   
  8.     call delete('ENVARC:0800mins')
  9.     call delete('ENV:0800mins')
  10.     exit
  11.     end
  12. ;;;
  13. /* ;;; Initialise */
  14. VerStr = '$VER: 0800Timer 1.0 (6.2.00)'
  15. VerStr = subword(VerStr,2)||'0a'x||'(c) Neil Bothwick, Wirenet'
  16. Usage  = 'INTERFACE,PROGRESS=BAR/S'
  17.  
  18. options results
  19. address command
  20.  
  21. if ~show('L','rexxsupport.library') then call addlib('rexxsupport.library',0,-30,0)
  22. if ~show('L','rexxdossupport.library') then call addlib('rexxdossupport.library',0,-30,0)
  23.  
  24. if ~exists('ENVARC:0800mins') then do
  25.     'echo >ENVARC:0800mins "0" noline'
  26.     'echo >ENV:0800mins "0" noline'
  27.     end
  28. TotalTime = GetVar('0800mins')
  29. ;;;
  30. /* ;;; Read arguments */
  31. parse arg args
  32. if right(args,1) = '?' | ~ReadArgs(args,Usage) then do
  33.     say 'Usage: 0800Timer' Usage
  34.     exit
  35.     end
  36.  
  37. if symbol('Interface') ~= 'VAR' then Interface = ''
  38. if show('P','GENESIS') & Interface = '' then Interface = 'ppp0'
  39. if ~IsOnline() then exit
  40. ;;;
  41. /* ;;;Open progress bar if required */
  42. if show('P','0800TIMER-PRG') then do
  43.     Progress = 1
  44.     address '0800TIMER-PRG' 'ONLINE' 
  45.     end
  46. else if Progress = 1 then do
  47.     parse source ScriptPath
  48.     call pragma('D',PathPart(word(ScriptPath,4)))
  49.     'Run >NIL: MUIRexx 0800Timer.mrx port 0800TIMER'
  50.     do i = 1 to 5 until RC = 0
  51.         'waitforport 0800TIMER-PRG'
  52.         end
  53.     end
  54. ;;;
  55. /* ;;; Main loop */
  56. do while IsOnline()
  57.     TotalTime = TotalTime + 1
  58.     'setenv 0800mins' TotalTime
  59.     'setenv ENVARC:0800mins' TotalTime
  60.     if Progress = 1 then do
  61.         if show('P','0800TIMER-PRG') then address '0800TIMER-PRG' TotalTime
  62.         else Progress = 0
  63.         end
  64.     call delay(3000)
  65.     end
  66. ;;;
  67. /* ;;; Clean up and exit */
  68. CleanUp:
  69.     if show('P','0800TIMER-PRG') then address '0800TIMER-PRG' 'OFFLINE'
  70.     exit
  71. ;;;
  72. /* ;;; Check if still online */
  73. IsOnline:
  74.     select
  75.         when show('P','MIAMI.1') then do
  76.             address 'MIAMI.1' 'ISONLINE' Interface
  77.             return RC
  78.             end
  79.         when show('P','GENESIS') then do
  80.             address 'GENESIS' 'ISONLINE' Interface
  81.             return RC
  82.             end
  83.         otherwise return 0
  84.         end
  85.     return 0
  86. ;;;
  87.  
  88.